import React,{useState} from "react"
import {SearchBar} from "antd-mobile"


const Component = (props)=>{
  const [value,setValue] = useState("")
  const handleChange = (value)=>{
    setValue(value)
  }
  const handleSubmit = ()=>{
    // 同步用法
    // props.dispatch({
    //   type:"search/getLists", // 参数为 models/search的命名空间和reducers的方法名
    //   payload:value
    // })
    // 异步用法
    props.dispatch({
      type:"search/getListsAsync", // 参数为 models/search的命名空间和reducers的方法名
      payload:value
    })
    
  }
  return (
    <div>
      <SearchBar
        autoFocus
        value={value}
        onChange={handleChange}
        onSubmit={handleSubmit}
      ></SearchBar>
    </div>
  )
}

export default Component